<?php

/**
 * This is the model class for table "phoria_distance".
 *
 * The followings are the available columns in table 'phoria_distance':
 * @property integer $id
 * @property string $ver_ph
 * @property string $bi
 * @property string $bo
 * @property string $lat_ph
 * @property string $l_bu
 * @property string $l_bd
 * @property integer $rx_id
 * @property integer $personalinfo_id
 *
 * The followings are the available model relations:
 * @property Rx $rx
 * @property PersonalInformation $personalinfo
 */
class PhoriaDistance extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return PhoriaDistance the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'phoria_distance';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('rx_id, personalinfo_id', 'numerical', 'integerOnly'=>true),
			array('ver_ph, bi, bo, lat_ph, l_bu, l_bd', 'length', 'max'=>5),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, ver_ph, bi, bo, lat_ph, l_bu, l_bd, rx_id, personalinfo_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'rx' => array(self::BELONGS_TO, 'Rx', 'rx_id'),
			'personalinfo' => array(self::BELONGS_TO, 'PersonalInformation', 'personalinfo_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'ver_ph' => 'Ver Ph',
			'bi' => 'Bi',
			'bo' => 'Bo',
			'lat_ph' => 'Lat Ph',
			'l_bu' => 'L Bu',
			'l_bd' => 'L Bd',
			'rx_id' => 'Rx',
			'personalinfo_id' => 'Personalinfo',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('ver_ph',$this->ver_ph,true);
		$criteria->compare('bi',$this->bi,true);
		$criteria->compare('bo',$this->bo,true);
		$criteria->compare('lat_ph',$this->lat_ph,true);
		$criteria->compare('l_bu',$this->l_bu,true);
		$criteria->compare('l_bd',$this->l_bd,true);
		$criteria->compare('rx_id',$this->rx_id);
		$criteria->compare('personalinfo_id',$this->personalinfo_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}